home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plptex.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  1KB  |  45 lines

  1. /* Prints out "text" at world cooordinate (x,y). The text may be       */
  2. /* at any angle "angle" relative to the horizontal. The parameter      */
  3. /* "just" adjusts the horizontal justification of the string:          */
  4. /*   just = 0.0 => left hand edge of string is at (x,y)                */
  5. /*   just = 1.0 => right hand edge of string is at (x,y)               */
  6. /*   just = 0.5 => centre of string is at (x,y) etc.                   */
  7. /* N.B. Centreline of the string passes through (x,y)                  */
  8.  
  9. #include "plplot.h"
  10. #include <math.h>
  11.  
  12. void plptex(x,y,dx,dy,just,text)
  13. float x,y,dx,dy,just;
  14. char *text;
  15. {      
  16.       int refx, refy;
  17.       float shift, cc, ss;
  18.       float xform[4],diag;
  19.       float xscl, xoff, yscl, yoff;
  20.    
  21.       int level;
  22.       glev(&level);
  23.       if (level < 3) fatal("Please set up window before calling PLPTEX.");
  24.  
  25.       gwm(&xscl,&xoff,&yscl,&yoff);
  26.       cc = xscl * dx;
  27.       ss = yscl * dy;
  28.       diag = sqrt(cc*cc + ss*ss);
  29.       cc = cc/diag;
  30.       ss = ss/diag;
  31.       
  32.       gmp(&xscl,&xoff,&yscl,&yoff);
  33.       shift = 0.0;
  34.       
  35.       xform[0] = cc;
  36.       xform[1] = -ss;
  37.       xform[2] = ss;
  38.       xform[3] = cc;
  39.  
  40.       if (just != 0.0) shift = plstrl(text) * just;
  41.       refx = wcpcx(x) - shift * cc * xscl;
  42.       refy = wcpcy(y) - shift * ss * yscl;
  43.       plstr(0,xform,refx,refy,text);
  44. }
  45.